<div class="x-body">
    <form class="layui-form" id="AdminUserEdit">
        <input type="hidden" name="id" value="">
        <input type="hidden" name="layerindex" id="layerindex" value="">
        <div class="layui-form-item">
            <label for="username" class="layui-form-label">
            <span class="x-red">*</span>账户
        </label>
            <div class="layui-input-inline">
                <input type="text" name="account" required="" lay-verify="required" value="admin" autocomplete="off" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">
                <span class="x-red">*</span>将会成为您唯一的登入名
            </div>
        </div>
        <div class="layui-form-item">
            <label for="phone" class="layui-form-label">
            <span class="x-red">*</span>名称
        </label>
            <div class="layui-input-inline">
                <input type="text" value="13671989456" name="nickname" lay-verify="required" autocomplete="off" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">
                <span class="x-red">*</span>将会成为您唯一的登入名
            </div>
        </div>
        <div class="layui-form-item">
            <label for="L_email" class="layui-form-label">
            <span class="x-red">*</span>邮箱
        </label>
            <div class="layui-input-inline">
                <input type="text" name="email" required="" lay-verify="required|email" value="826096331@qq.com" autocomplete="off" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">
                <span class="x-red">*</span>
            </div>
        </div>
        <div class="layui-form-item">
            <label for="role" class="layui-form-label">
            <span class="x-red">*</span>角色
        </label>
            <div class="layui-input-inline">
                <select name="roleid">
                <option value="0">请选择</option>
                <volist name="rolelist" id="vo">
                    <option value="{$vo.id}">{$vo.title}</option>
                </volist>
            </select>
            </div>
        </div>
        <div class="layui-form-item">
            <label for="L_pass" class="layui-form-label">
            <span class="x-red">*</span>状态
        </label>
            <div class="layui-input-inline">
                <select name="status">
                <option value="0">请选择</option>
                <option value="启用">启用</option>
                <option value="禁用">禁用</option>
            </select>
            </div>
            <div class="layui-form-mid layui-word-aux">
                6到16个字符
            </div>
        </div>
        <div class="layui-form-item">
            <label for="L_repass" class="layui-form-label">
            <span class="x-red">*</span>备注
        </label>
            <div class="layui-input-inline">
                <input type="text" name="remark" required="" lay-verify="repass" value="123456" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label for="L_repass" class="layui-form-label">
        </label>
            <button class="layui-btn" lay-filter="save" lay-submit="">保存</button>
        </div>
    </form>
</div>
<script>
    form.render();
    //自定义验证规则
    form.verify({
        nikename: function(value) {
            if (value.length < 5) {
                return '昵称至少得5个字符啊';
            }
        },
        pass: [/(.+){6,12}$/, '密码必须6到12位'],
        repass: function(value) {
            if ($('#L_pass').val() != $('#L_repass').val()) {
                return '两次密码不一致';
            }
        }
    });

    //监听提交
    form.on('submit(save)', function(data) {
        $.ajax({
            url: '{:U("User/edit")}',
            type: "post",
            data: data.field,
            dataType: 'json',
            success: function(r) {
                layer.msg(r.info);
                if (r.status) {
                    layer.close($('#layerindex').val());
                    table.reload('AdminUserDt');
                }
            }
        });
        return false;
    });
</script>